package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class Serv extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		//获取应用程序路径
		//ctxPath=/servlet_jsp_02
		String ctxPath = request.getContextPath();
		PrintWriter out = response.getWriter();
		// /img/girl.jpg;  "/"servlet_jsp_02/img/girl.jpg  "/"是指ip:port
		//url相对路径
		out.println("<img src=\"img/girl.jpg\"/>");
		//url绝对路径
		out.println("<img src=\""+ctxPath+"/img/girl.jpg\"/>");
		out.println("<img src=\"/servelet_jsp_01/img/girl.jpg\"/>");
	}
}
